<?php

namespace app\common\model\service;

use app\common\model\BaseModel;
use app\common\model\hfztcy\LibStore;

//公共函数

/**
 * 门店登录
 * @name LibStoreLogin.php
 * @package hfztcy
 * @category model
 * @link http://www.chanekeji.com
 * @author rxy
 * @version 1.0
 * @copyright CHANGE INC
 * @since 2022-06-17
 */
class LibStoreLogin extends BaseModel
{
    public $username;
    public $password;

    public $model;

    public function __construct($username,$password)
    {
        $this->username = $username;
        $this->password = trim($password);
        $this->model = new LibStore();
        parent::__construct();
    }

    private function _form ()
    {
        return [
            'username' => $this->username,
            'password' => $this->password
        ];
    }

    public function login ()
    {
        $result = $this->checkForm();
        if ($result['errorCode'] == 0) {
            return $this->getStore();
        } else {
            return $result;
        }
    }

    private function checkForm ()
    {
        return $this->model->goCheck($this->_form(),'login');
    }

    private function getStore ()
    {
        return $this->model->findStore($this->_form());
    }
}

?>